<template>
	<view>
		<view class="box">
			<view class="timer">
				
					<text>还剩</text>
					<view class="shijian">{{countdownh}}</view>
					<text>时</text>
					<view class="shijian">{{countdownm}}</view>
					<text>分</text>
					<view class="shijian">{{countdowns}}</view>
					<text>秒</text>
				</view>
			</view>
			<view class="item">
				<span>多选题</span>
				<span>第1题</span>
			</view>
			<view class="item">
				<span>多选题2</span>
			</view>

			<view class="kuang">
				<view class="border">
					<view class="itemlist">
						<p>A</p>
						<p>多选1</p>
					</view>
					<view class="itemlist">
						<p>A</p>
						<p>多选1</p>
					</view>
					<view class="itemlist">
						<p>A</p>
						<p>多选1</p>
					</view>
				</view>
			</view>
		</view>




	</view>
</template>

<script>
	import {
		kaoshilist
	} from "@/api/user.js"
	export default {
		data() {
			return {
				id: "",
				countdownh: '',
				countdownm: '',
				countdowns: '',
				timer: null, //重复执行
			}


		},
		onLoad() {
			this.id = this.$route.query.type
			console.log(this.id);
			this.getdata(),
				this.timer = setInterval(() => {
					this.showtime()
				})

		},
		methods: {
			//时间
			showtime() {
				var nowtime = new Date(), //获取当前时间
					endtime = new Date("2022/12/10"); //定义结束时间
				var lefttime = endtime.getTime() - nowtime.getTime(), //距离结束时间的毫秒数
					leftd = Math.floor(lefttime / (1000 * 60 * 60 * 24)), //计算天数
					lefth = Math.floor((lefttime / (1000 * 60 * 60) % 24) + leftd * 24) < 10 ? "0" + Math.floor((lefttime /
						(1000 * 60 * 60) % 24) + leftd * 24) : Math.floor((lefttime / (1000 * 60 * 60) % 24) + leftd *
						24), //计算小时数
					leftm = Math.floor(lefttime / (1000 * 60) ) < 10 ? "0" + Math.floor(lefttime / (1000 * 60) % 60) :
					Math.floor(lefttime / (1000 * 60) % 60), //计算分钟数
					lefts = Math.floor(lefttime / 1000 % 60) < 10 ? "0" + Math.floor(lefttime / 1000 % 60) : Math.floor(
						lefttime / 1000 % 60); //计算秒数
				this.countdownh = lefth //返回倒计时的字符串
				this.countdownm = leftm //返回倒计时的字符串
				this.countdowns = lefts //返回倒计时的字符串
				// 倒计时结束时，显示00:00:00
				if (lefttime < 0) {
					this.countdownh = this.countdownm = this.countdowns = "00"
				}
			},

			async getdata() {
				const res = await kaoshilist({id:this.id})
				console.log(res);
			}
		}
	}
</script>

<style scoped lang="scss">
	.kuang {
		width: 750rpx;
		height: 300rpx;
		background-color: white;

		.border {
			width: 700rpx;
			height: 280rpx;
			margin: auto;
			background-color: white;

			.itemlist {
				width: 600rpx;
				height: 70rpx;
				border: 2px solid red;
				margin: auto;
				border-radius: 10rpx;
				display: flex;
				align-items: center;
				margin-top: 20rpx;

				p {
					margin-left: 20rpx;
					font-size: 20rpx
				}

				&:active {
					color: green;
					border: 2px solid green;
				}
			}
		}
	}

	* {
		box-sizing: border-box;
	}

	.timer {
		margin-top: 5rpx;
		width: 750rpx;
		height: 100rpx;
		border: 1px solid red;
		display: flex;
		align-items: center;
		justify-content: center;

		p {
			font-size: 40rpx;
			font-weight: bold;
		}
	}

	.item {
		width: 750rpx;
		height: 50rpx;
		background-color: white;
		justify-content: space-between;
		padding-left: 30rpx;
		padding-right: 30rpx;
		display: flex;
		align-items: center;
	}
</style>
